<%--
  Created by IntelliJ IDEA.
  User: konley
  Date: 2020/6/13
  Time: 15:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="pojo.Student" %>
<%@ page import="pojo.Card" %>
<%@ page import="pojo.Bill" %>
<%@ page import="java.util.List" %>
<%@ page import="pojo.Manager" %>
<html>
<head>
    <title>学生页 | 校园一卡通</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/css.css"/>
    <script src="${pageContext.request.contextPath }/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/js/jquery-3.4.1.js" type="text/javascript"
            charset="utf-8"></script>
    <style type="text/css">
        body {
            background-image: url("photo/bg.jpg");
        }
    </style>
</head>
<body>
<!--top-->
<div style="background-color:#444;">
    <div class="container">
        <div class="row">
            <h2 style="color: white;font-weight: bold;">校园一卡通系统 | <span style="color: #FF6666;">管理学生</span></h2>
        </div>
    </div>
</div>
<div class="container">
    <br>
    <%
        Student stu = (Student) request.getAttribute("student");
        Card card = (Card) request.getAttribute("card");
        List<Bill> bills = (List<Bill>) request.getAttribute("bills");
    %>
    <br>
    <div class="row">
        <div class="panel-primary panel">
            <div class="panel-body">
                <%  String msg = request.getAttribute("msg")+"";
                    if(request.getAttribute("msg")!=null){
                        if(msg.equals("null"))
                            msg=null;
                     }
                    if (msg != null ) {
                %>
                <div class="alert alert-success" style="text-align: center">提示：<%=request.getAttribute("msg")%>
                </div>
                <br>
                <% } %>
                <div class="col-sm-6">
                    <table class="table table-bordered">
                        <tbody>
                        <tr>
                            <td>学号：</td>
                            <td><%=stu.getSid()%>
                            </td>
                        </tr>
                        <tr>
                            <td>姓名：</td>
                            <td><%=stu.getName()%>
                            </td>
                        </tr>
                        <tr>
                            <td>密码：</td>
                            <td><%=stu.getPassword()%>
                            </td>
                        </tr>
                        <tr>
                            <td>性别：</td>
                            <td><%=stu.getSex()%>
                            </td>
                        </tr>
                        <tr>
                            <td>系别：</td>
                            <td><%=stu.getDept()%>
                            </td>
                        </tr>
                        <tr>
                            <td>联系电话：</td>
                            <td><%=stu.getTel()%>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="col-sm-6">
                    <h4>卡号：<kbd><%=card.getCid()%>
                    </kbd></h4>
                    <br>
                    <h4>当前余额：<span style="color: #c7254e"><%=card.getMoney()%>.00元</span></h4>
                    <h4>最大可存余额：<span style="color:dodgerblue">1000.00元</span></h4>
                    <br>
                    <div class="progress progress-striped active">
                        <div class="progress-bar progress-bar-success" role="progressbar"
                             style="width: <%=card.getMoney()/10%>%;">
                        </div>
                    </div>
                    <div style="text-align: left;margin-top: 8%">
                        <a href="ManagerServlet?m=toAddCardMoney&cid=<%=card.getCid()%>">
                            <button type="button" class="btn btn-success btn-sm">为此饭卡充值</button>
                        </a>
                        <a href="ManagerServlet?m=doUpdate&id=<%=stu.getSid()%>">
                            <button type="button" class="btn btn-info btn-sm">修改学生信息</button>
                        </a>
                        <script type="text/javascript">
                            function confirmdel() {
                                if (confirm("确认删除该学生以及账号下余额、账单等所有记录，该操作不可逆 ！"))
                                    return true;
                                return false;
                            }
                        </script>
                        <a href="ManagerServlet?m=delete&sid=<%=stu.getSid()%>&cid=<%=card.getCid()%>"
                           onclick="return confirmdel();">
                            <button type="button" class="btn btn-danger btn-sm">删除学生</button>
                        </a>
                        <a href="managerView.jsp" style="margin-left: 34.5%">
                            <button type="button" class="btn btn-primary btn-sm">返回管理端</button>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--消费记录-->
    <div class="row">
        <div class="panel panel-info">
            <div class="panel-heading">
                <h2 class="panel-title">账号消费记录</h2>
            </div>
            <div class="panel-body">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <strong>
                            <td>账单号</td>
                            <td>消费类型</td>
                            <td>金额</td>
                            <td>地点</td>
                            <td>日期</td>
                        </strong>
                    </tr>
                    </thead>
                    <tbody>
                    <% for (Bill bill : bills) { %>
                    <% String color = bill.getType().equals("消费") ? "darkred" : "green";%>
                    <tr>
                        <td><%=bill.getBid()%>
                        </td>
                        <td style="color:<%=color%>">
                            <%=bill.getType()%>
                        </td>
                        <td style="color:<%=color%>"><%=bill.getMoney()%>.00元</td>
                        <td><%=bill.getAddress()%>
                        </td>
                        <td><%=bill.getTime()%>
                        </td>
                    </tr>
                    <% } %>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>

